﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JwtDemoWebApi.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace JwtDemoWebApi.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Authorize]
    public class PatientController : BaseController
    {
        private readonly ILogger<PatientController> _logger;

        public PatientController(ILogger<PatientController> logger)
        {
            _logger = logger;
        }

        [AllowAnonymous]
        [HttpGet]
        public async Task<string> GetByPatientId(long patientId)
        {
            return await Task.FromResult($"GetByPatientId:{patientId}");
        }

        [HttpPost]
        public async Task<Patient> CreateorUpdatePatient([FromBody] Patient patient)
        {
            var claims = this.claims;
            patient.PatientName = "PatientName";
            return await Task.FromResult(patient);
        }

        [Authorize(Roles = "ClaimRole")]
        [HttpGet]
        public async Task<string> IndexRole()
        {
            return await Task.FromResult($"IndexRole");
        }


        [Authorize(Policy = "AdminPolicy")]
        [HttpGet]
        public async Task<string> IndexPolicy()
        {
            return await Task.FromResult($"IndexPolicy");
        }

        [Authorize(Policy = "DoubleEmail")]
        [HttpGet]
        public async Task<string> IndexPolicyDouble()
        {
            return await Task.FromResult($"IndexPolicyDouble");
        }
    }
}
